package com.dt.dubai.gaug.controller;

import com.dt.dubai.gaug.entity.GaugEntrustReportEntity;
import com.dt.dubai.gaug.controller.innate.GaugEntrustReportInnateAbs;
import com.dt.dubai.core.comm.*;
import com.dt.dubai.core.utile.DateTools;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Date;
import java.util.List;
import java.util.Map;

/*
* 委托检测报告记录表
*/

@Controller
@RequestMapping(value = "/gaug/gaugEntrustReport")
public class GaugEntrustReportController extends GaugEntrustReportInnateAbs {

    /*innateServiceStart*/
    @Override
    protected void userSavEntity(GaugEntrustReportEntity inEntity, final Long userId) {
        inEntity.setDelSign(false);
    }

    @Override
    protected void userModEntity(GaugEntrustReportEntity inEntity, final Long userId) {
    }

    @Override
    protected void userDelByKey(List<Long> recordIds, final Long userId) {
    }

    @Override
    protected void userQueByKey(Long recordId, Map<String, Object> map, final Long userId) {
        if (null != map && map.size() > 0) {
            map.put("createTxStamp", DateTools.dateFormat((Date) map.get("createTxStamp"), DateTools.DATE_FORMAT_YMD));
            map.remove("delSign");
            map.remove("lastupTxStamp");
        }
    }

    @Override
    protected void userQuePageList(PageParameterData queryCondition, List<PageCondition> joinCondition, List<Map<String, Object>> resultMap, final Long userId) {
        for (Map<String, Object> map : resultMap) {
            map.put("createTxStamp", DateTools.dateFormat((Date) map.get("createTxStamp"), DateTools.DATE_FORMAT_YMD));
            Integer reportStamp = null == map.get("reportStamp") ? -1 :  (Integer) map.get("reportStamp");
            switch (reportStamp) {
                case 1:
                    map.put("reportStamp", reportStamp);
                    map.put("reportStampStr", "无");
                    break;
                case 2:
                    map.put("reportStamp", reportStamp);
                    map.put("reportStampStr", "CNAS");
                    break;
                case 3:
                    map.put("reportStamp", reportStamp);
                    map.put("reportStampStr", "CNAS");
                    break;
                case 4:
                    map.put("reportStamp", reportStamp);
                    map.put("reportStampStr", "CNAS_CMA");
                    break;
                default:
                    map.put("reportStamp", -1);
                    map.put("reportStampStr", "未知");
            }
            Integer reportType = null == map.get("reportType") ? -1 :  (Integer) map.get("reportType");
            switch (reportType) {
                case 1:
                    map.put("reportType", reportType);
                    map.put("reportTypeStr", "中文");
                    break;
                case 2:
                    map.put("reportType", reportType);
                    map.put("reportTypeStr", "英文");
                    break;
                case 3:
                    map.put("reportType", reportType);
                    map.put("reportTypeStr", "中英");
                    break;
                case 4:
                    map.put("reportType", reportType);
                    map.put("reportTypeStr", "双语");
                    break;
                case 5:
                    map.put("reportType", reportType);
                    map.put("reportTypeStr", "中双语");
                    break;
                case 6:
                    map.put("reportType", reportType);
                    map.put("reportTypeStr", "英双语");
                    break;
                case 7:
                    map.put("reportType", reportType);
                    map.put("reportTypeStr", "全部");
                    break;
                default:
                    map.put("reportType", -1);
                    map.put("reportTypeStr", "未知");
            }
            Short accountsStatus = null == map.get("accountsStatus") ? -1 :  (Short) map.get("accountsStatus");
            switch (accountsStatus) {
                case 1:
                    map.put("accountsStatus", accountsStatus);
                    map.put("accountsStatusStr", "已下订单");
                    break;
                case 2:
                    map.put("accountsStatus", accountsStatus);
                    map.put("accountsStatusStr", "已接单");
                    break;
                case 3:
                    map.put("accountsStatus", accountsStatus);
                    map.put("accountsStatusStr", "检测中");
                    break;
                case 4:
                    map.put("accountsStatus", accountsStatus);
                    map.put("accountsStatusStr", "已检毕");
                    break;
                case 5:
                    map.put("accountsStatus", accountsStatus);
                    map.put("accountsStatusStr", "报告完成");
                    break;
                default:
                    map.put("accountsStatus", -1);
                    map.put("accountsStatusStr", "未知");
            }
            Boolean abolishStatus = null == map.get("abolishStatus") ? false : (Boolean) map.get("abolishStatus");
            if (abolishStatus) {
                map.put("abolishStatus", abolishStatus);
                map.put("abolishStatusStr", "是");
            } else {
                map.put("abolishStatus", abolishStatus);
                map.put("abolishStatusStr", "否");
            }
            map.remove("delSign");
            map.remove("lastupTxStamp");
        }
    }

    /*innateServiceEnd*/
    /*以上内容请误删除或是移动，系统升级使用，用户代码请写入下方*/
}